<html>
<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" %>
<%@include file="/quick/include/common.jsp"%>
<%@include file="/quick/include/globalScope.jsp"%>
  <head>
    <title><c:out value="${model.title}"/></title>
  </head>
<script>
Ext.onReady(function(){
	var yearStore=new Ext.data.SimpleStore({
     'fields':['value','text'],
     data:<c:out value="${model.yearJson}" escapeXml='false' />
	});
	var semesterStore=new Ext.data.SimpleStore({
     'fields':['value','text'],
     data:<c:out value="${model.semesterJson}" escapeXml='false' />
	});
	
	var form = new Ext.form.FormPanel({
	      labelAlign:'right',
	      title:'成绩维护',
	      labelWidth:100,
	      region:'north',
	      autoHeight:true,
	      frame:true,
	      width:380,
		  url:g_rootPath+'ajax/system/parameter/save.html',	      
	      items:[{
            xtype:'combo',   
            fieldLabel:'学年度',  
            store: yearStore,   
            editable: false,   
            hiddenName:'SCHOOL_YEAR',   
            id:'_SCHOOL_YEAR',   
            displayField:'text',   
            valueField:'value',   
            typeAhead:true,   
            mode: 'local',   
            triggerAction: 'all',   
            emptyText:'请选择',   
            selectOnFocus:true,   
            resizable:true,   
            allowBlank:false,   
            anchor:'90%',
            forceSelection:true           
         },{
            xtype:'combo',   
            fieldLabel:'学期',   
            store: semesterStore,   
            editable: false,   
            hiddenName:'SCHOOL_SEMESTER',   
            id:'_SCHOOL_SEMESTER',   
            displayField:'text',   
            valueField:'value',   
            typeAhead:true,   
            mode: 'local',   
            triggerAction: 'all',   
            emptyText:'请选择',   
            selectOnFocus:true,   
            resizable:true,   
            allowBlank:false,   
            anchor:'90%',
            forceSelection:true           
         },{  
            xtype:'pairfield',
            hideLabel:true,
		    label:'课号',
		    id:'c_course',
		    name:'courseNo',
		    click:_click,
		    query:_qureyCourse
		},{  
            xtype:'textfield',
		    fieldLabel:'课程序号',
		    id:'c_class',
		    width:240,
		    name:'classNo'
		},{  
            xtype:'pairfield',
            hideLabel:true,
		    label:'学号',
		    id:'c_student',
		    name:'studentNo',
		    click:_click,
		    query:_qureyStudent
		}],
         buttons:[{text:'确定',handler:function(){
           _confirm(form);
         }},{text:'重置',handler:function(){
           form.getForm().reset();
         }}] 
          
	});
	form.render('parameter_form');   
   
});

function _confirm(form){
  var schoolYear=form.findById('_SCHOOL_YEAR').getValue();
  var schoolSemester=form.findById('_SCHOOL_SEMESTER').getValue();
  var studentNo=form.findById('c_student').getValue();
  var classNo=form.findById('c_class').getValue();
  var courseNo=form.findById('c_course').getValue();
  var matrix=[['tableName','V_ORIGINAL_SCORE_DETAIL'],['SCHOOL_YEAR',schoolYear],['SCHOOL_SEMESTER',schoolSemester],['STUDENT_NO',studentNo],['CLASS_NO',classNo],['COURSE_NO',courseNo]];
  var f=createForm(g_rootPath+'quick/quick.html',matrix);
  f.submit();
}

function _click(){

}
function _qureyCourse(){
  var courseNo=this.getValue();
  var pairField=this;
  if(courseNo==null||courseNo=="") return;
  Ext.Ajax.request({
    method:'POST',
    url:g_rootPath+'ajax/findCourseByNo.html',
    params:{courseNo:courseNo},
    success:function(response){
      var resp=Ext.decode(response.responseText);
       if(resp.success){
         pairField.setText(resp.course.courseName);
       }else{
         pairField.setValue('');
         pairField.setText('');
         Ext.Msg.alert('<fmt:message key="label.info"/>',resp.errorInfo);
         
       }
    },
    failure:function(){}
  });

}


function _qureyStudent(){
  var sno=this.getValue();
  var pairField=this;
  if(sno==null||sno=="") return;
  Ext.Ajax.request({
    method:'POST',
    url:g_rootPath+'ajax/findStudentByNo.html',
    params:{studentNo:sno},
    success:function(response){
      var resp=Ext.decode(response.responseText);
       if(resp.success){
         pairField.setText(resp.student.studentName);
       }else{
         pairField.setValue('');
         pairField.setText('');
         Ext.Msg.alert('<fmt:message key="label.info"/>',resp.errorInfo);
         
       }
    },
    failure:function(){}
  });
}
</script>  
    <c:if test="${not empty message}">
      <div  align="left" id="title" style="height:40px;vertical-align:bottom;bgcolor:blue;"><br><h3><STRONG><c:out value='${message}'/></STRONG></h3></div>
    </c:if>

<br>
<br>
<br>
<div id="parameter_form" align=center></div>    



  
</html>   
